package com.func.domain.activity.service.quota.rule.factory;

import com.func.domain.activity.service.quota.rule.IActionChain;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * DefaultActivityChainFactory
 * </p>
 *
 * @author Simon
 * @version 2025.03.12.1.0.0
 * @description 抽奖规则责任链装配工厂
 * @since 2025-03-12
 */

@Service
public class DefaultActivityChainFactory {

    private final Map<String, IActionChain> actionChainGroup;

    public DefaultActivityChainFactory(Map<String, IActionChain> actionChainGroup) {
        this.actionChainGroup = actionChainGroup;
    }

    public IActionChain openActionChain(){
        IActionChain current = actionChainGroup.get(ActionModel.activity_base_action.getCode());
        IActionChain actionChain = current;
        current.appendNext(actionChainGroup.get(ActionModel.activity_sku_stock_action.getCode()));
        return actionChain;
    }

    @Getter
    @AllArgsConstructor
    public enum ActionModel{
        activity_base_action("activity_base_action", "活动的库存, 时间校验"),
        activity_sku_stock_action("activity_sku_stock_action", "活动sku库存"),
        ;

        private final String code;
        private final String info;
    }
}
